package org.pine.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ ClassName HelloController
 * @ Description: Session 共享测试
 * @ Author lzs
 * @ Date 2021-02-01
 * @ Version V1.0
 */
@RestController
@RequestMapping("/session")
public class HelloController {

    @Value("${server.port}")
    String port;
    @PostMapping("/save")
    public String saveName(String name, HttpSession session){
        session.setAttribute("name","madder");
        return port;
    }

    @GetMapping("/get")
    public String getName(HttpSession session){
        return port+":"+session.getAttribute("name").toString();
    }

}
